package com.cxhc.app.api.hcdoc;


import com.cxhc.app.api.hcdoc.vo.HdBranchBudgetModifyLogVo;
import com.cxhc.app.api.hcdoc.vo.HdBranchBudgetVo;
import com.cxhc.app.api.hcdoc.vo.HdUserInfoVo;
import com.cxhc.app.api.mapper.hcdoc.HcDocUserMapStructMapper;
import com.cxhc.app.api.mapper.hcdoc.HdBranchBudgetMapStructMapper;
import com.cxhc.app.api.mapper.hcdoc.HdBranchBudgetModifyLogMapStructMapper;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.core.page.TableDataInfo;
import com.cxhc.common.utils.StringUtils;
import com.cxhc.system.domain.hcdoc.HdBranchBudget;
import com.cxhc.system.domain.hcdoc.HdBranchBudgetModifyLog;
import com.cxhc.system.domain.hcdoc.HdUserInfo;
import com.cxhc.system.service.hcdoc.HcDocUserService;
import com.cxhc.system.service.hcdoc.HdBranchBudgetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 预算金额信息Controller
 *
 * @author Dhq
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/api/hcDoc/hdBranchBudget")
public class HdBranchBudgetApi extends BaseController {

    @Autowired
    private HdBranchBudgetService hdBranchBudgetService;

    /**
     * 获取预算金额详细信息 之后写
     */
    @RequestMapping(value = "/getInfoById")
    public AjaxResult getInfoById(String id) {
        return success(hdBranchBudgetService.selectById(id));
    }

    /**
     * 获取预算金额详细信息 之后写
     */
    @RequestMapping(value = "/getInfoByIdForProject")
    public AjaxResult getInfoByIdForProject(String branchInfoId) {
        return success(hdBranchBudgetService.selectByIdForProject(branchInfoId));
    }

    /**
     * 新增预算金额
     */
    @RequestMapping("/insert")
    public AjaxResult insert(@RequestBody HdBranchBudgetVo hdBranchBudgetVo) {
        HdBranchBudget hdBranchBudget = HdBranchBudgetMapStructMapper.INSTANCE.HdBranchBudgetVoToHdBranchBudget(hdBranchBudgetVo);
        return toAjax(hdBranchBudgetService.insertHdBranchBudget(hdBranchBudget));
    }

    /**
     * 查询预算金额列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HdBranchBudgetVo hdBranchBudgetVo) {
        HdBranchBudget hdBranchBudget = HdBranchBudgetMapStructMapper.INSTANCE.HdBranchBudgetVoToHdBranchBudget(hdBranchBudgetVo);
        startPage();
        return getDataTable(hdBranchBudgetService.selectList(hdBranchBudget));
    }

    /**
     * 更新预选金额信息
     */
    @GetMapping("/update")
    public AjaxResult update(HdBranchBudgetVo hdBranchBudgetVo) {
        HdBranchBudget hdBranchBudget = HdBranchBudgetMapStructMapper.INSTANCE.HdBranchBudgetVoToHdBranchBudget(hdBranchBudgetVo);
        return toAjax(hdBranchBudgetService.update(hdBranchBudget));
    }

    /**
     * 更新预算单位预算金额
     */
    @RequestMapping("/updateBudgetAmount")
    public AjaxResult updateBudgetAmount(@RequestBody HdBranchBudgetModifyLogVo hdBranchBudgetModifyLogVo) {
        HdBranchBudgetModifyLog hdBranchBudgetModifyLog = HdBranchBudgetModifyLogMapStructMapper.INSTANCE.HdBranchBudgetModifyLogVoToHdBranchBudgetModifyLog(hdBranchBudgetModifyLogVo);
        return toAjax(hdBranchBudgetService.updateBudgetAmount(hdBranchBudgetModifyLog));
    }
}
